package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.SecondProduct;
import cn.wolfcode.crm.mapper.SecondProductMapper;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.ISecondProductService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
class SecondProductServiceImpl implements ISecondProductService {

    @Autowired
    private SecondProductMapper secondProductMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return secondProductMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(SecondProduct record) {
        return secondProductMapper.insert(record);
    }

    @Override
    public SecondProduct selectByPrimaryKey(Long id) {
        return secondProductMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<SecondProduct> selectAll() {
        return secondProductMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(SecondProduct record) {
        return secondProductMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageResult query(QueryObject qo) {

        int total = secondProductMapper.queryForCount(qo);
        if (total == 0) {
            return new PageResult();
        }

        List list = secondProductMapper.queryForList(qo);
        return new PageResult(total, list);
    }
}
